; ModuleID = 'MAlice'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-linux-gnu"

%letter = type i8
%number = type i32
%sentence = type i8*

@.fmt_d = private constant [3 x i8] c"%d\00", align 1 ; <[3 x i8]*> [#uses=1]
@.io.error = private constant [53 x i8] c"IOError: Could not read integer from standard input!\00", align 1 ; <[53 x i8]*> [#uses=0]
@.fmt_s = private constant [3 x i8] c"%s\00", align 1 ; <[3 x i8]*> [#uses=1]
@.fmt_c = private constant [5 x i8] c"'%c'\00", align 1 ; <[5 x i8]*> [#uses=0]
@0 = private constant [2 x i8] c"\0A\00", align 1 ; <[2 x i8]*> [#uses=1]

declare i32 @printf(i8*, ...)

declare i32 @scanf(i8*, ...)

declare void @abort()

define i32 @fib(i32 %n) {
entry:
  %n.param = alloca i32                           ; <i32*> [#uses=5]
  store i32 %n, i32* %n.param
  br label %body

body:                                             ; preds = %entry
  %tmp = getelementptr i32* %n.param, i32 0       ; <i32*> [#uses=1]
  %n1 = load i32* %tmp                            ; <i32> [#uses=1]
  %tmp8 = icmp ule i32 %n1, 1                     ; <i1> [#uses=1]
  br i1 %tmp8, label %if.then, label %if.else

if.then:                                          ; preds = %body
  %tmp9 = getelementptr i32* %n.param, i32 0      ; <i32*> [#uses=1]
  %n2 = load i32* %tmp9                           ; <i32> [#uses=1]
  ret i32 %n2
  br label %if.merge

if.else:                                          ; preds = %body
  br i1 true, label %if.then4, label %if.else3

if.then4:                                         ; preds = %if.else
  %tmp10 = getelementptr i32* %n.param, i32 0     ; <i32*> [#uses=1]
  %n5 = load i32* %tmp10                          ; <i32> [#uses=1]
  %tmp11 = sub i32 %n5, 1                         ; <i32> [#uses=1]
  %"<call>" = call i32 @fib(i32 %tmp11)           ; <i32> [#uses=1]
  %tmp12 = getelementptr i32* %n.param, i32 0     ; <i32*> [#uses=1]
  %n6 = load i32* %tmp12                          ; <i32> [#uses=1]
  %tmp13 = sub i32 %n6, 2                         ; <i32> [#uses=1]
  %"<call>7" = call i32 @fib(i32 %tmp13)          ; <i32> [#uses=1]
  %"+" = add i32 %"<call>", %"<call>7"            ; <i32> [#uses=1]
  ret i32 %"+"
  br label %if.merge

if.else3:                                         ; preds = %if.else
  br label %if.merge

if.merge:                                         ; preds = %if.else3, %if.then4, %if.then
  ret i32 0
}

define i32 @main(i32 %argc, i8** %argv) {
entry:
  %argc.param = alloca i32                        ; <i32*> [#uses=1]
  store i32 %argc, i32* %argc.param
  %argv.param = alloca i8**                       ; <i8***> [#uses=1]
  store i8** %argv, i8*** %argv.param
  %i = alloca i32                                 ; <i32*> [#uses=5]
  br label %body

body:                                             ; preds = %entry

  %fib5 = call i32 @fib(i32 5)              ; <i32> [#uses=1]
  store i32 %fib5, i32* %i
	call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @.fmt_d, i64 0, i64 0), i32* %i) ; <i32> [#uses=0]

  %tmp = getelementptr i32* %i, i32 0             ; <i32*> [#uses=1]
  %tmp4 = call i32 (i8*, ...)* @scanf(i8* noalias getelementptr inbounds ([3 x i8]* @.fmt_d, i64 0, i64 0), i32* %tmp) nounwind ; <i32> [#uses=0]
  %tmp5 = getelementptr i32* %i, i32 0            ; <i32*> [#uses=1]
  %tmp6 = getelementptr i32* %i, i32 0            ; <i32*> [#uses=1]
  %i1 = load i32* %tmp6                           ; <i32> [#uses=1]

  %"<call>" = call i32 @fib(i32 %i1)              ; <i32> [#uses=1]
  store i32 %"<call>", i32* %tmp5
  %tmp7 = getelementptr i32* %i, i32 0            ; <i32*> [#uses=1]
  %i2 = load i32* %tmp7                           ; <i32> [#uses=0]
  %tmp8 = getelementptr i32* %i, i32 0            ; <i32*> [#uses=1]
  %printf = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @.fmt_d, i64 0, i64 0), i32* %tmp8) ; <i32> [#uses=0]
  %printf3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @.fmt_s, i64 0, i64 0), [2 x i8]* @0) ; <i32> [#uses=0]
  ret i32 0
}

